home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Financial / Stopwatch2.3 / Source / SortList.h < prev    next >
Text File  |  1995-06-12  |  2KB  |  70 lines

  1. /*
  2.  * For legal stuff see the file COPYRIGHT
  3.  */
  4. #import <objc/List.h>
  5.  
  6. @interface SortList : List
  7. {
  8.   id    delegate ;        // an object that knows how to compare elements 
  9.   SEL    sortMethod;        // method used to sort
  10.   SEL    compareMethod;        // method used to compare to key values
  11.   SEL    valueMethod;        // method for getting key value
  12.   id    compObject;        // object which will do actual comparison
  13.   SEL    compMethod;        // method which will be used to do comparison
  14.   BOOL    sorted;            // whether the list is sorted
  15.   BOOL    autoSort;        // whether the list sorts itself automatically
  16. }
  17.  
  18. // overridden methods
  19. - initCount:(unsigned int)numSlots;
  20. - (unsigned int)indexOf:anObject;
  21. - addObject:anObject;
  22. - addObjectIfAbsent:anObject;
  23. - insertObject:anObject at:(unsigned int)index;
  24. - replaceObject:anObject with:newObject;
  25. - replaceObjectAt:(unsigned int)index with:newObject;
  26.  
  27. - update;
  28. - (BOOL)isSorted;
  29. - setAutoSort:(BOOL)sortFlag;
  30. - (BOOL)doesAutoSort;
  31.  
  32. - setDelegate:obj;
  33. - delegate;
  34. - useSortMethod:(SEL)method;
  35. - (SEL)sortMethod;
  36. - useComparisonMethod:(SEL)method;
  37. - (SEL)comparisonMethod;
  38. - useValueMethod:(SEL)method;
  39. - (SEL)valueMethod;
  40.  
  41. - sort;
  42. - insertObject:anObject;
  43. - mergeList:otherList;
  44. - (unsigned int)indexOfObjectWithKey:proxyObject;
  45.  
  46. - shellsort;
  47. - (int)compare:object1 :object2;
  48.  
  49. @end
  50.  
  51. @interface SortingListDelegate
  52. /*
  53.  * Delegated comparitor method.  Delegate must compare the two objects
  54.  * and return a number < 0 if object1 < object2, 0 if object1 = object2, and a
  55.  * number greater than 0 if object1 > object2 in whatever way makes sense to
  56.  * the application.  The delegate can use the valueMethods already set or
  57.  * ignore them and use its own.
  58.  */
  59. - (int)compare:object1 :object2;
  60.  
  61. /*
  62.  * Delegated sort method (optional).  Delegate may implement its own sorting
  63.  * routine (though it kinda defeats the whole purpose of this object).  The
  64.  * SortList will send itself as the argument.  Note that the delegate can
  65.  * access the comparisonMethods and valueMethods already assigned or can
  66.  * ignore them and use its own.
  67.  */
  68. - sort:aList;
  69. @end
  70.